<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var str = '惊天秘密，你知我知';
        console.log(str.indexOf('知'));//6
        console.log(str.lastIndexOf('知'));//6

        console.log(str[3]);//密
        //charAt() 返回对应索引的字符
        console.log(str.charAt(3));//密
        //charCodeAt()  返回对应的索引的acall码
        console.log(str.charCodeAt(3)); //23494 
    </script>
</body>
</html>